import java.util.HashMap;
import java.util.Map;


public class DNSDatabase {
	private Map<String, DomainInfo> database;
	
	public DNSDatabase()
	{
		database = new HashMap<String, DomainInfo>();
	}
	
	public synchronized DomainInfo searchDomain(String domain)
	{
		return database.get(domain);
	}
	
	public synchronized void registerDomain(DomainInfo info)
	{
		database.put(info.getDomain(), info);
	}
	
	public static DNSDatabase databaseGenerator()
	{
		DNSDatabase database = new DNSDatabase();
		database.registerDomain(new DomainInfo("unisa", "182.122.1.23", "Università degli Studi di Salerno", "owner@unisa.it"));
		database.registerDomain(new DomainInfo("facebook", "72.34.2.13", "Facebook", "owner@facebook.com"));
		database.registerDomain(new DomainInfo("twitter", "70.2.13.241", "Twitter", "owner@twitter.com"));
		return database;
	}
}
